Skip to content

Conversation

@abhakat
Copy link
Contributor

@abhakat abhakat commented Sep 22, 2025

What changed / motivation ?

context

Linked PR/Issues

Fixes #1217

Additional Context

npm test passes

updated the snapshots for anything my changes impact

Pre-flight checklist

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 22, 2025
Copy link
Member

@mellyeliu mellyeliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for taking this on! Some follow ups :)

@mellyeliu mellyeliu changed the title Polyfill float values [babel-plugin][legacy] Polyfill logical float values Sep 22, 2025
{
"ltr": ".xodj72a{clear:right}",
"rtl": ".xodj72a{clear:left}",
"rtl": ".xodj72a{clear:var(--1t497je)}",
Copy link
Member

@mellyeliu mellyeliu Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, we should be seeing this as the output:

   "ltr": ".xodj72a{clear:var(--1t497je)}"",
   "rtl": null,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮 I had that earlier but thought it was wrong

might have to change some of the logic

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing the float mappings in generateRtl should fix it :)

the context is with this change we can get rid of the rtl field completely! we'll have one value that autoflips


// Export both the expansions object and the processing function
export default expansions as typeof expansions;
export { processProperty };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I will remove it

}> = {
float: ([key, val]) => [key, logicalToPhysical[val] ?? val],
clear: ([key, val]) => [key, logicalToPhysical[val] ?? val],
start: `var(${LOGICAL_FLOAT_END_VAR})`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking closer, the float mapping in legacy-expand-shorthands should be enough, we don't need to add handling in generate-rtl.js or generate-rtl.js, we just need to remove the blocks listed in #1217

Comment on lines 84 to 87
start: `var(${LOGICAL_FLOAT_END_VAR})`,
end: `var(${LOGICAL_FLOAT_START_VAR})`,
'inline-start': `var(${LOGICAL_FLOAT_END_VAR})`,
'inline-end': `var(${LOGICAL_FLOAT_START_VAR})`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
start: `var(${LOGICAL_FLOAT_END_VAR})`,
end: `var(${LOGICAL_FLOAT_START_VAR})`,
'inline-start': `var(${LOGICAL_FLOAT_END_VAR})`,
'inline-end': `var(${LOGICAL_FLOAT_START_VAR})`,

Comment on lines 29 to 33
if (value === 'inline-start') {
return [[property, `var(${LOGICAL_FLOAT_START_VAR})`]];
} else if (value === 'inline-end') {
return [[property, `var(${LOGICAL_FLOAT_END_VAR})`]];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (value === 'inline-start') {
return [[property, `var(${LOGICAL_FLOAT_START_VAR})`]];
} else if (value === 'inline-end') {
return [[property, `var(${LOGICAL_FLOAT_END_VAR})`]];
}
if (value === 'inline-start' || value === 'start') {
return [[property, `var(${LOGICAL_FLOAT_START_VAR})`]];
} else if (value === 'inline-end' || value === 'end') {
return [[property, `var(${LOGICAL_FLOAT_END_VAR})`]];
}

@mellyeliu
Copy link
Member

Almost, just a couple more fixes!

Copy link
Member

@mellyeliu mellyeliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good! Let's hold off on merging this for now because this will involve a prerequisite change on the Haste side

@github-actions
Copy link

github-actions bot commented Oct 30, 2025

workflow: benchmarks/perf

Comparison of performance test results, measured in operations per second. Larger is better.

[email protected] compare
node ./compare.js /tmp/tmp.Yuovy0JzdA /tmp/tmp.ZNcnazMLZM

Results Base Patch Ratio
babel-plugin: stylex.create
· basic create 615 611 0.99 -
· complex create 80 78 0.97 -
babel-plugin: stylex.createTheme
· basic themes 441 422 0.96 -
· complex themes 42 40 0.95 -

@github-actions
Copy link

github-actions bot commented Oct 30, 2025

workflow: benchmarks/size

Comparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.

[email protected] compare
node ./compare.js /tmp/tmp.nXT2jPfgm7 /tmp/tmp.kHpnuqgNKW

Results Base Patch Ratio
@stylexjs/stylex/lib/cjs/stylex.js
· compressed 1,282 1,282 1.00
· minified 4,025 4,025 1.00
@stylexjs/stylex/lib/cjs/inject.js
· compressed 1,223 1,223 1.00
· minified 3,216 3,216 1.00
benchmarks/size/.build/bundle.js
· compressed 496,650 496,650 1.00
· minified 4,847,840 4,847,840 1.00
benchmarks/size/.build/stylex.css
· compressed 99,853 99,853 1.00
· minified 747,541 747,541 1.00

{
"ltr": ".xodj72a{clear:right}",
"rtl": ".xodj72a{clear:left}",
"ltr": ".xodj72a{clear:end}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

output needs to be: .xodj72a{clear: var(--stylex-logical-end)}


import splitValue from '../utils/split-css-value';

export const LOGICAL_FLOAT_START_VAR = '--stylex-logical-end';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add logic here to map float: start and float: inline-start to float: var(LOGICAL_FLOAT_START_VAR)

Copy link
Member

@mellyeliu mellyeliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just missing the processStylexRules change that seem to be lost in the merge. Will stamp after that!

Copy link
Member

@mellyeliu mellyeliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff. Thanks for sitting through all the iterations! Please add back the cleanup in generate-ltr and generate-lrtl before merging

@mellyeliu mellyeliu merged commit 825a79a into main Nov 5, 2025
9 checks passed
@mellyeliu mellyeliu deleted the polyfill-float-values branch November 5, 2025 03:29
hiteshshetty-dev pushed a commit to hiteshshetty-dev/stylex that referenced this pull request Nov 8, 2025
* addressed Melissa' suggestions

* More changes that are hopefully correct

* Version that doesn't check for float and clear

* The first version is probably correct as it passes all the other suites, going to use it

* last bit of changes missed + updating tests

---------

Co-authored-by: Anay Bhakat <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[babel-plugin][legacy] Polyfill float values for legacy browser support

4 participants